﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace RuEn_Test
{
    [TestFixture]
    public class CoreEngineTest
    {
        private Test_BO test_bo;

        [Test]
        public void RequiredRuleNegative_Test()
        {
            test_bo = new Test_BO();
            test_bo.Address = "test_address";
            test_bo.Name = string.Empty;
            test_bo.Validate(test_bo);
            Assert.Contains("Error: Required Rule Failed", test_bo.BrokenRules, "Required Rule Failed");
        }

        [Test]
        public void LengthMinRuleNegative_Test()
        {
            test_bo = new Test_BO();
            test_bo.Address = "test_address";
            test_bo.Name = "a";
            test_bo.Validate(test_bo);
            Assert.Contains("Error: Length Rule Failed", test_bo.BrokenRules, "Min Length Rule Failed");
        }

        [Test]
        public void LengthMaxRuleNegative_Test()
        {
            test_bo = new Test_BO();
            test_bo.Address = "test_address";
            test_bo.Name = "123456789012345678901";
            test_bo.Validate(test_bo);
            Assert.Contains("Error: Length Rule Failed", test_bo.BrokenRules, "Max Length Rule Failed");
        }

        [Test]
        public void RegExRuleNegative_Test()
        {
            test_bo = new Test_BO();
            test_bo.Address = "test_address";
            test_bo.Name = "aaaa";
            test_bo.Validate(test_bo);
            Assert.Contains("Error: RegEx Rule Failed", test_bo.BrokenRules, "Regex Rule Failed");
        }

        [Test]
        public void ComparerEquelRuleNegative_Test()
        {
            test_bo = new Test_BO();
            test_bo.Address = "test_address";
            test_bo.Name = "aaaa";
            test_bo.Validate(test_bo);
            Assert.Contains("Error: Comparision Rule Failed", test_bo.BrokenRules, "Equel Compare Rule Failed");
        }

        [Test]
        public void ComparerNotEquelRuleNegative_Test()
        {
            test_bo = new Test_BO();
            test_bo.Address = "test_address";
            test_bo.Name = "test_comparer";
            test_bo.Email = "test_comparer";
            test_bo.Validate(test_bo);
            Assert.Contains("Error: Comparision Rule Failed", test_bo.BrokenRules, "Not EquelCompare Rule Failed");
        }

        [Test]
        public void ComparerGreaterRuleNegative_Test()
        {
            test_bo = new Test_BO();
            test_bo.Address = "test_address";
            test_bo.Name = "test_comparer";
            test_bo.Age1 = 8;
            test_bo.Validate(test_bo);
            Assert.Contains("Error: Comparision Rule Failed", test_bo.BrokenRules, "Greater Compare Rule Failed");
        }

        [Test]
        public void ComparerLessRuleNegative_Test()
        {
            test_bo = new Test_BO();
            test_bo.Address = "test_address";
            test_bo.Name = "test_comparer";
            test_bo.Age2 = 10;
            test_bo.Validate(test_bo);
            Assert.Contains("Error: Comparision Rule Failed", test_bo.BrokenRules, "Less Compare Rule Failed");
        }

    }
}
